#ifndef ENTITYOBJECT_H
#define ENTITYOBJECT_H

#include <core/entity.h>

#include <QtScript>
#include <QtDeclarative>
#include <log4qt/logger.h>
#include <qsharedpointer.h>

namespace Opl
{
	namespace Core
	{

		class CORE_EXPORT Notify
		{
			public:
				Notify() {}
				virtual ~Notify() {}
		};


		/*!
		 \brief
		 Class contain feauters QObject and Entity, also is base object for all declarative scripts

		 \sa Entity
		*/
		class CORE_EXPORT EntityObject : public QObject, public Entity
		{
				Q_OBJECT
				Q_PROPERTY(QVariant tag READ tag WRITE setTag)
				Q_PROPERTY(QUuid unique READ unique)
				Q_PROPERTY(QDateTime unique READ stamp)
				Q_PROPERTY(QDeclarativeListProperty<QObject> childerns READ childerns DESIGNABLE false)
				Q_CLASSINFO("DefaultProperty", "childerns")
				LOG4QT_DECLARE_QCLASS_LOGGER
			public:
				static QString ID;
				QDeclarativeListProperty<QObject> childerns();
				/*!
				 \brief

				 \return QString reprezentatnion current EntityObject as QString
				*/
				virtual QString toString();


				EntityObject(EntityObject* parent = 0);
				virtual ~EntityObject();

				virtual void notify(const Notify& n);

				static void fromScriptValue(const QScriptValue& object, EntityObject*& out);
				static QScriptValue toScriptValue(QScriptEngine* engine, EntityObject* const& in);
				static QScriptValue construct_Script(QScriptContext*, QScriptEngine* engine);

			private:
				static void child_append(QDeclarativeListProperty<QObject>* prop, QObject* o);
		};

		typedef QSharedPointer<EntityObject> EntityPtr;

	}
}

Q_DECLARE_METATYPE(Opl::Core::EntityObject*)
#endif // ENTITYOBJECT_H
